package blue_bridge_cup_learning.双指针;

import java.util.Scanner;

public class 两数之和 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int target = scan.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scan.nextInt();
        }
        int count = 0;
        int lower = 0, right = arr.length - 1;
        while (lower < right) {
            int total = arr[lower] + arr[right];
            if (total > target) {
                right--;
            }
            if (total < target) {
                lower++;
            }
            if (total == target) {
                lower++;
                count++;
            }
        }
        System.out.print(count);
        scan.close();
    }
}